const generate = require('nanoid/generate')
Parse.Cloud.beforeSave('RcMember', async (req, res) => {
  try {
    const member = req.object
    if (!member.id) {
      const code = generate('0123456789', 5)
      member.set('code', code)
    }
    res.success(member)
  } catch (err) {
    res.error(err.message)
  }
})
